-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Guide: articulate the advantages of ownership over garbage collection. #18176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
borrowed from you, you must not have lent out that pointer to anyone else. | ||
is immutable, then there are no problems. But if it's mutable, the result of | ||
changing it can vary unpredictably depending on who happens to access it first, | ||
called a **race condition**. To avoid this, if someone wants to mutate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this 'which is called', please?
Thank you! Just one or two little nits. |
Explain the primary disadvantage of garbage collection is runtime overhead and unpredictable pauses. Elucidate where the name "race condition" comes from. Emphasize that Rust can guarantee your code is free of race conditions and other memory errors, with no runtime overhead.
4f07eff
to
f0b7065
Compare
Good point! Here you go. |
I am on mobile so this will get screwed up, r=me |
Explain the primary disadvantage of garbage collection is runtime overhead and unpredictable pauses. Elucidate where the name "race condition" comes from. Emphasize that Rust can guarantee your code is free of race conditions and other memory errors, with no runtime overhead. cc @steveklabnik
rules are broken. If our program compiles successfully, Rust can guarantee it | ||
is free of data races and other memory errors, and there is no runtime overhead | ||
for any of this. The borrow checker works only at compile time. If the borrow | ||
checker did find a problem, it will report a **lifetime error**, and your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct (cc @nikomatsakis).
"Lifetime errors" come from regionck, which infers appropriate lifetimes and enforces their coherence.
The borrowck produces, well, borrow errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is particularly important to be too pedantic about the internal compiler passes, but maybe this sentence could be rephrased to just "it will report an error and your program will refuse to compile".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, they are two different compiler passes because they have different jobs, and produce different errors.
Calling borrow errors "lifetime errors" is plain wrong, AFAIK they don't even mention lifetimes, the only conceptual link is that borrows are determined by lifetimes.
And it propagates the misconception that the borrow checker assigns lifetimes or gives errors about them - does not help explaining errors or tracking them down at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is particularly important to be too pedantic about the internal compiler passes, but maybe this sentence could be rephrased to just "it will report an error and your program will refuse to compile".
Agreed.
…nikomatsakis see #18176 (comment) /cc @eddyb @huonw @nikomatsakis
Explain the primary disadvantage of garbage collection is runtime
overhead and unpredictable pauses. Elucidate where the name "race
condition" comes from. Emphasize that Rust can guarantee your code is
free of race conditions and other memory errors, with no runtime
overhead.
cc @steveklabnik